<?php
require_once(dirname(dirname(__FILE__)) . '/app.php');
need_login();
need_admin();

if ( $_POST ) {
	$table = new Table('user', $_POST);
	$up_array = array(
		'email', 'username', 'realname', 'gender', 'mobile', 'qq', 'address',
	);
	//如果修改密码
	if ($table->password ) {
		$table->password = ZUser::GenPassword($table->password);
		$up_array[] = 'password';
	}
	
	$flag = $table->update($up_array);
	if ( $flag ) {
		Session::Set('notice', '修改员工信息成功');
		die("<script>parent.location.reload();</script>");
	}
	Session::Set('error', '修改员工信息失败');
	die("<script>parent.location.reload();</script>");
}